//
//  BZThreadQueue.h
//  MZBasic
//
//  Created by Sings on 2023/7/6.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@class BZThreadQueueTask;

typedef void(^BZThreadQueueTaskFinishedBlock)(BOOL Next);
typedef void(^BZThreadQueueTaskBlock)(BZThreadQueueTaskFinishedBlock finished);
typedef void(^BZThreadQueueFinishedBlock)(BOOL Success);

@interface BZThreadQueue : NSObject

/// 任务名称
@property (nonatomic, copy) NSString *strLabel;

/// 同任务的并发数，默认为1（串行：当有同名新任务加入是需等待之前任务做完）
@property (nonatomic, assign) NSUInteger iConcurrency;

/// 任务数组
@property (nonatomic, strong, readonly) NSMutableArray<BZThreadQueueTask *> *marTask;

/// 完成回调
@property (nonatomic, copy) BZThreadQueueFinishedBlock finished;

- (void) addTask:(BZThreadQueueTask *) task;

@end

@interface BZThreadQueueTask : NSObject

@property (nonatomic, readonly, copy) BZThreadQueueTaskBlock task;

- (instancetype) initWithAction:(BZThreadQueueTaskBlock) task;

@end

NS_ASSUME_NONNULL_END
